<html>

<head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="dependencies/jquery.js"></script>
    <script src="dependencies/md5.js"></script>
    <script>
        function login() {
            var loginUrl = "http://47.108.67.131/timetable_api/v1/timetables";
            var param = '?';
            var account = $("#user [name=account]").val();
            var password = $("#user [name=password]").val();
            password = MD5(password);
            var plan_code = "2021-2022-1-1";
            param += "account=" + account + "&";
            param += "password=" + password + "&";
            param += "plan_code=" + plan_code;
            console.log(loginUrl + param);

            $.ajax({
                url: loginUrl + param,
                type: "GET",
                dataType: 'jsonp',
                complete: function (xhr, text) {
                    console.log(xhr.status);
                    if (xhr.status == 200) {
                        alert("成功登录");
                        window.location.href = "mainpage.html" + param;
                    } else {
                        alert("账号或密码错误");
                    }
                }
            });
            return false;
        }
    </script>
</head>

<body>
    <h1>教务管理系统</h1>
    <div>
        <form id='user' onsubmit="return login();">
            学号:<br>
            <input type="text" name="account">
            <br>
            密码:<br>
            <input type="password" name="password">
            <br><br>
            <input type="submit" value="登录">
        </form>

    </div>
</body>


</html>